home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / JORF21_2.ZIP / CONFLDS.J < prev    next >
Text File  |  1993-07-05  |  12KB  |  379 lines

  1. Class:ConFlds
  2.   Index:PagePos
  3.   Index:Prompt
  4.   Index:Field
  5.   Page
  6.   Row
  7.   Col
  8.   Len
  9.   Wid
  10.   PrWid
  11.   Type
  12.   NumFormat
  13.   Radiovalue
  14.   Before
  15.   After
  16.   Action
  17.  
  18. ConFlds:Start
  19.   New (ConFlds:ConFlds,ConPage:Page)
  20.   Jorf:File("CONFLDS.DAT",Here)
  21.   Event:Add()
  22.   Mem:Ptr->ConIndex='PagePos'
  23.   ConFlds=ConFlds:Next(ConFlds,'Next')
  24.  
  25.   Win:Add ("Contact Field Management")
  26.     Menu:"&File"
  27.       Menu:"&Generate"               Action:"ConFlds:Generate()"
  28.       Menu:"&Rebuild"                Action:"ConFlds:Rebuild()"
  29.       Menu:""
  30.       Menu:"E&xit       Alt-X"       Action:"Return(Null)"
  31.     Menu:"&Edit"
  32.       Menu:"&Add"       Action:"ConFlds:Edit(ConFlds,'Add')"
  33.       Menu:"&Change"    Action:"ConFlds:Edit(ConFlds,'Change')"
  34.       Menu:"&Delete"    Action:"ConFlds:Edit(ConFlds,'Delete')"
  35.     Menu:"&Search",
  36.       Menu:"&Page       ",  Action:"ConFlds:KeySearch (ConFlds,'Page' ,'PagePos')
  37.       Menu:"P&rompt     ",  Action:"ConFlds:KeySearch (ConFlds,'Prompt', 'Prompt')
  38.       Menu:"&Field      ",  Action:"ConFlds:KeySearch (ConFlds,'Field' , 'Field')
  39.     Group:"&ConFldss", Row:1, Col:1, Len:16, Wid:42
  40.     String:"Prompt        Page Col Row  Field Name"
  41.     List:"" Row:3, Col:2, Len:14, Wid:42
  42.       Field:"ConFlds"
  43.       Next:"ConFlds:Next(ConFlds,'Next')"
  44.       Prev:"ConFlds:Next(ConFlds,'Prev')"
  45.       Show:"ConFlds:Show(ConFlds)'
  46.     Button:"&Ok"      Row:19 Col:5  Wid:14 Action:"Return(Null)"
  47.     Button:"&Cancel"  Row:19 Col:25 Wid:14 Action:"Return('Esc_Key')"
  48.   Return (Ok)
  49.  
  50. Class:ConPage
  51.   Index:PageNo
  52.   Text
  53.  
  54. ConFlds:BeforeLen()
  55.   If (Str:In('HLine,Group,Text',ConFlds->Type)==0)
  56.     ConFlds->Len=Null
  57.     Return (Null)
  58.   Return (Ok)
  59.  
  60. ConFlds:BeforeWid()
  61.   If (Str:In('Radio,ChBox,Prompt',ConFlds->Type))
  62.     ConFlds->Wid=Null
  63.     Return (Null)
  64.   Return (Ok)
  65.  
  66. ConFlds:CheckCol(Col)
  67.   If (Col < 1 OR Col > 76)
  68.     Msg:Add
  69.       You must enter a column &
  70.       between 1 and 76.
  71.     Return (Null)
  72.   Return (Ok)
  73.  
  74. ConFlds:CheckField(Field)
  75.   New (i,c)
  76.   If (Str:In(Field," ")
  77.     Msg:Add
  78.       You cannot have embedded spaces
  79.       in your field name.  If you want,
  80.       you can use an _underscore.
  81.     Return (Null)
  82.   If (To:Num(Str:At(Field,1,1)))
  83.     Msg:Add
  84.       You cannot begin a field name
  85.       with a number.
  86.     Return (Null)
  87.   For (i = 1 thru str:len(field))
  88.     c=To:Ucs(Str:At(Field,i,1))
  89.     If ((C < "A" Or C > "Z") And C!='_')
  90.       Msg:Add
  91.         Illegal character "{C}".  You must
  92.         use only alphabetic characters in
  93.         a field name.
  94.       Return (Null)
  95.   Return (Ok)
  96.  
  97. ConFlds:CheckPage(Page)
  98.   If (Page < 1 OR Page > 99)
  99.     Msg:Add
  100.       You must enter a page number &
  101.       between 1 and 99.
  102.     Return (Null)
  103.   Return (Ok)
  104.  
  105. ConFlds:CheckRow(Row)
  106.   If (Row < 1 OR Row > 15)
  107.     Msg:Add
  108.       You must enter a row &
  109.       between 1 and 15.
  110.     Return (Null)
  111.   Return (Ok)
  112.  
  113. ConFlds:CheckWid(Wid)
  114.   If (Wid < 1 OR Wid > 76)
  115.     Msg:Add
  116.       You must enter a width &
  117.       between 1 and 76.
  118.     Return (Null)
  119.   Return (Ok)
  120.  
  121. ConFlds:Edit(*ConFlds,Action)
  122.   | Add/Edit/Delete ConFldss
  123.   New (ConFlds:NewConFlds, ConPage:Page,Result)
  124.  
  125.   Switch (Action)
  126.     Case "Add"
  127.       Jorf:Write(NewConFlds)
  128.       ConFlds=NewConFlds
  129.       Jorf:Lock(NewConFlds)
  130.  
  131.     Case "Change"
  132.       If (Jorf:Lock(ConFlds)==Null)
  133.         Win:Msg("Record is locked.  Cannot change right now.")
  134.         Return (Ok)
  135.       Page=Struct:Find('ConPage','PageNo',ConFlds->Page)
  136.       If (Page->Text)
  137.         Page->Text=Null
  138.         Jorf:Write(Page)
  139.     Case "Notes"
  140.       If (Jorf:Lock(ConFlds)==Null)
  141.         Win:Msg("Record is locked.  Cannot change right now.")
  142.         Return (Ok)
  143.       ConFlds:Page('Notes')
  144.       Kbd:Put("End_Key")
  145.       Kbd:Get()
  146.       Jorf:Write(ConFlds)
  147.       Return (Ok)
  148.     Case "Delete"
  149.       Result=Msg:Add('ConFlds Delete','No')
  150.         Delete this Field?
  151.  
  152.         Page:   {ConFlds->Page}  Row: {ConFlds->Row}  Col: {ConFlds->Col}
  153.         Prompt: {ConFlds->Prompt}
  154.         Field:  {ConFlds->Field}
  155.       If (Result)
  156.         Jorf:Del(ConFlds)
  157.         Page=Struct:Find('ConPage','PageNo',ConFlds->Page)
  158.         If (Page->Text)
  159.           Page->Text=Null
  160.           Jorf:Write(Page)
  161.         Win:Dsp
  162.       Kbd:Put("Home_Key")
  163.       Return(Ok)
  164.  
  165.   Win:Add ("{Action} Field")
  166.     Group:"" Row:1 Col:1 Len:2 Wid:46
  167.     Input:"&Prompt" Row:2 Col:2 Wid:39 Field:"ConFlds->Prompt"
  168.     Input:"N&ame  " Row:3 Col:2 Wid:14 Field:"ConFlds->Field"
  169.       After:"ConFlds:CheckField(ConFlds->Field)"
  170.     Input:"Page" Row:3 Col:25 Wid:2  Field:"ConFlds->Page" Type:"Number"
  171.       After:"ConFlds:CheckPage(ConFlds->Page)"
  172.     Input:"Prompt Width" Row:3 Col:33 Wid:2  Field:"ConFlds->PrWid" Type:"Number"
  173.       After:"ConFlds:CheckPage(ConFlds->Page)"
  174.     Group:"Type" Row:5 Col:1 Len:6 Wid:46
  175.     Radio:"Normal &Input " Row:6 Col:2
  176.       Check:"ConFlds->Type=='Normal'"
  177.       Action:"ConFlds->Type='Normal'"
  178.       UnAction:"ConFlds->Type=Null"
  179.     Radio:"&Date input   " Row:7 Col:2
  180.       Check:"ConFlds->Type=='Date'"
  181.       Action:"ConFlds->Type='Date'"
  182.       UnAction:"ConFlds->Type=Null"
  183.     Radio:"&Numeric input" Row:8 Col:2
  184.       Check:"ConFlds->Type=='Number'"
  185.       Action:"ConFlds->Type='Number'"
  186.       UnAction:"ConFlds->Type=Null"
  187.     Input:"Format"        Row:9 Col:5  Wid:16  Field:"ConFlds->NumFormat"
  188.     Radio:"&Text input   " Row:10 Col:2
  189.       Check:"ConFlds->Type=='Text'"
  190.       Action:"ConFlds->Type='Text'"
  191.       UnAction:"ConFlds->Type=Null"
  192.     Radio:"Chec&k Box"     Row:6 Col:28
  193.       Check:"ConFlds->Type=='ChBox'"
  194.       Action:"ConFlds->Type='ChBox'"
  195.       UnAction:"ConFlds->Type=Null"
  196.     Radio:"&Radio Button"  Row:7 Col:28
  197.       Check:"ConFlds->Type=='Radio'"
  198.       Action:"ConFlds->Type='Radio'"
  199.       UnAction:"ConFlds->Type=Null"
  200.     Input:"Value"         Row:8 Col:31 Wid:10  Field:"ConFlds->RadioValue"
  201.     Radio:"&Prompt only  " Row:9 Col:28
  202.       Check:"ConFlds->Type=='Prompt'"
  203.       Action:"ConFlds->Type='Prompt'"
  204.       UnAction:"ConFlds->Type=Null"
  205.     Radio:"Hori&zontal line"          Row:10 Col:28
  206.       Check:"ConFlds->Type=='HLine'"
  207.       Action:"ConFlds->Type='HLine'"
  208.       UnAction:"ConFlds->Type=Null"
  209.     Radio:"&Group box"           Row:11 Col:28
  210.       Check:"ConFlds->Type=='Group'"
  211.       Action:"ConFlds->Type='Group'"
  212.       UnAction:"ConFlds->Type=Null"
  213.     Group:"Position" Row:1 Col:50 Len:4 Wid:9
  214.     Input:"Ro&w   " Row:2 Col:51 Wid:2  Field:"ConFlds->Row"  Type:"Number"
  215.       After:"ConFlds:CheckRow(ConFlds->Row)"
  216.     Input:"Co&lumn" Row:3 Col:51 Wid:2  Field:"ConFlds->Col" Type:"Number"
  217.       After:"ConFlds:CheckCol(ConFlds->Col)"
  218.     Input:"L&ength" Row:4 Col:51 Wid:2  Field:"ConFlds->Len" Type:"Number"
  219.       Before:"ConFlds:BeforeLen()"
  220.       After:"ConFlds:CheckWid(ConFlds->Wid)"
  221.     Input:"Widt&h " Row:5 Col:51 Wid:2  Field:"ConFlds->Wid" Type:"Number"
  222.       Before:"ConFlds:BeforeWid()"
  223.       After:"ConFlds:CheckWid(ConFlds->Wid)"
  224.     Group:"Extra Processing" Row:13 Col:1 Len:3 Wid:58
  225.     Input:"&Before " Row:14 Col:2 Wid:50  Len:1 Field:"ConFlds->Before"
  226.     Input:"A&fter  " Row:15 Col:2 Wid:50  Len:1 Field:"ConFlds->After"
  227.     Input:"Action " Row:16 Col:2 Wid:50   Len:1 Field:"ConFlds->Action"
  228.     Button:"&Ok"       Row:7  Col:50 Wid:10 Action:"Return(Null)"
  229.     Button:"&Cancel"   Row:10  Col:50 Wid:10 Action:"Return('Esc_Key')"
  230.  
  231.   ConFlds->PagePos=Num:Str(ConFlds->Page,"###",10,3)+" "+Num:Str(ConFlds->Col,"##",10,2)+" "+Num:Str(ConFlds->Row,"##",10,2)
  232.   Jorf:Write(ConFlds)
  233.   Page=Struct:Find('ConPage','PageNo',ConFlds->Page)
  234.   If (Page->Text)
  235.     Page->Text=Null
  236.     Jorf:Write(Page)
  237.   Win:Dsp
  238.   Return(Ok)
  239.  
  240. ConFlds:Generate(PageNo)
  241.   New (Line,Text,ConFlds:ConFlds)
  242.   If (PageNo==0)
  243.     Win:Add("Generate")
  244.       Input:"Page number to generate?", Field:"PageNo" Wid:2
  245.     If (Kbd:Got=="Esc_Key" Or PageNo==0)
  246.       Return (Null)
  247.  
  248.   Win:Add
  249.     Generating page {PageNo}
  250.   Jorf:File("CONFLDS.DAT",Here)
  251.   ConFlds=Struct:Find('ConFlds','PagePos',Num:Str(PageNo,"###",10,3))
  252.   While (ConFlds)
  253.     If (ConFlds->PrWid)
  254.       If (Str:I